<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>库存管理</title>
<script type="text/javascript">
$(function(){
	$('#dg').datagrid({    
		toolbar: [{
            
			
			//增加功能
			iconCls : 'icon-add',
			text : '商品入库',
			handler : function() {
				//显示窗口
				$('#win').window('open');  				
				//清空文本框
				$('#tb1').textbox('clear');
				$('#tb2').textbox('clear');
				$('#tb3').textbox('clear');
				$('#tb4').textbox('clear');
				$('#tb5').textbox('clear');
				$('#tb6').textbox('clear');
				$('#tb7').textbox('clear');
				$('#tb8').textbox('clear')}
		},'-',{
			iconCls: 'icon-edit',
			text:'修改库存',
			handler: function(){alert('修改库存')}
		},'-',{
			iconCls: 'icon-remove',
			text:'删除库存',
			handler: function(){
				var se = $('#dg').datagrid('getSelections');
				if (se.length > 0) {
					$.messager.confirm('确认对话框', '确定要删除吗？', function(r) {
						if (r) {
							$.each(se, function(i, n) {
								var pId = se[i].pId;
								$.ajax({
									type : 'post',
									url : 'removeShs',
									data : {
										'pId' : pId
									},
									dataType : 'json',
									success : function(data) {
										if (1 == data) {
											$.messager.show({
												title : '我的消息',
												msg : '删除成功',
												showType : 'show',
												timeout : 2000,
											})
											//重加载页面
											$('#dg').datagrid('reload');
										} else {
											$.messager.show({
												title : '我的消息',
												msg : '删除失败',
												showType : 'show',
												timeout : 2000,
											});
										}
									}
								})
							})
						} else {
							//取消所选中的行
							$('#dg').datagrid('clearSelections');
						}
					})
				} else {
					$.messager.alert('我的消息', '请勾选您要删除的行', 'info');
				}

			}
		}],
	    url:'showShs',
	    columns:[[    
            {field:'ck',width:100,checkbox:true},    
	        {field:'pId',title:'商品编号',width:100,align:'center',hidden:true},    
	        {field:'pName',title:'商品名称',width:100,align:'center'},    
	        {field:'pType',title:'品牌型号',width:100,align:'center'},
	        {field:'pAmount',title:'库存数量',width:100,align:'center'},    
	        {field:'pClass',title:'商品类型',width:100,align:'center'},    
	        {field:'pCost',title:'商品进价',width:100,align:'center'},
	        {field:'pPrice',title:'商品预售价',width:100,align:'center'},    
	        {field:'pTime',title:'入库时间',width:100,align:'center'},    
	        {field:'supId',title:'供应商ID',width:100,align:'center'}
	    ]],
	    fitColumns:true,
	    rownumbers:true,
	    pagePosition:'bottom',
	    pagination:true,
        
	});
	
	
	
	
})
</script>
</head>
<body>
<table id="dg"></table>  
<br>

	<!-- 增加功能的表格 -->

	<div id="win" class="easyui-window" title="My Window" style="width:600px;height:400px"   
        data-options="iconCls:'icon-save',modal:true,closed:true">
		
			<div id="insert" style="margin-left: 150px;margin-top: 70px">
			商品名称<input id="tb1" class="easyui-textbox" style="width:200px;heigh:20px"><br>
			品牌型号<input id="tb2" class="easyui-textbox" style="width:200px;heigh:20px"><br>
			商品数量<input id="tb3" class="easyui-textbox" style="width:200px;heigh:20px"><br>
			商品类型<input id="tb4" class="easyui-textbox" style="width:200px;heigh:20px"><br>
			商品进价<input id="tb5" class="easyui-textbox" style="width:200px;heigh:20px"><br> 
			商品预售价<input id="tb6" class="easyui-textbox" style="width:200px;heigh:20px"><br> 
			入库时间<input id="tb7" class="easyui-textbox" style="width:200px;heigh:20px"><br> 
			供应商ID<input id="tb8" class="easyui-textbox" style="width:200px;heigh:20px"><br> 
			<div style="margin-left: 100px; margin-top: 30px">
				<a id="btn1" href="#" class="easyui-linkbutton">确定</a> 
				<a id="btn2" href="#" class="easyui-linkbutton">取消</a> 
			</div>
		</div>
	</div>
			<!-- 修改功能的表格 -->

	<div id="win1" class="easyui-window" title="My Window" style="width:600px;height:400px"   
        data-options="iconCls:'icon-save',modal:true,closed:true">
		
			<div id="update" style="margin-left: 150px;margin-top: 70px">
		<div style="display:none">	supId<input id="tb9" class="easyui-textbox" style="width:200px;heigh:20px"><br><br></div> 
			供应商名称<input id="tb5" class="easyui-textbox" style="width:200px;heigh:20px"> <br><br> 
			厂家联系人<input id="tb6" class="easyui-textbox" style="width:200px;heigh:20px"><br> <br> 
			联系人电话<input id="tb7" class="easyui-textbox" style="width:200px;heigh:20px"><br> <br> 
			超市联络人<input id="tb8" class="easyui-textbox" style="width:200px;heigh:20px"> <br> <br>
			<div style="margin-left: 100px; margin-top: 30px">
				<a id="btn3" href="#" class="easyui-linkbutton">确定</a> 
				<a id="btn4" href="#" class="easyui-linkbutton">取消</a> 
			</div>
		</div>
	</div>
</body>
</html>